#include <iostream>

using namespace std;

template <typename T>
T gcd(T a, T b)
{
        if (a < b) swap(a, b);
        if (b == 0)
                return a;
        else
                return gcd(b, a%b);
}

int main()
{
        int n, m;
        cin >> n >> m;
        cout << gcd(n, m) << endl;
        return 0;
}